package com.stone.redis.lock.domain.bo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * 锁基本信息
 *
 * @author Mr_wenpan@163.com 2021/7/24 3:20 下午
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class LockInfo {

    /**
     * 锁的名称
     */
    private String name;
    /**
     * 获取锁的线程唯一标识（可重入锁使用）
     */
    private String threadUniqueIdentifier;
    /**
     * 等待时间
     */
    private long waitTime;
    /**
     * 锁过期自动释放时间
     */
    private long leaseTime;
    /**
     * 锁等待的时间单位（默认秒）
     */
    private TimeUnit timeUnit = TimeUnit.SECONDS;
    /**
     * key集合，用于批量获取锁
     */
    private List<String> keyList;

    public LockInfo(String name, long waitTime, long leaseTime, TimeUnit timeUnit) {
        this.name = name;
        this.waitTime = waitTime;
        this.leaseTime = leaseTime;
        this.timeUnit = timeUnit;
    }

    public LockInfo(String name, List<String> keyList, long waitTime, long leaseTime, TimeUnit timeUnit) {
        this.name = name;
        this.keyList = keyList;
        this.waitTime = waitTime;
        this.leaseTime = leaseTime;
        this.timeUnit = timeUnit;
    }

}